package com.wangcang.widgetlibrary.chart;

import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.wangcang.widgetlibrary.R;

/**
 * @author Joseph on 2017/7/20.
 *         <p/>
 */

public class ChartActivity extends AppCompatActivity implements ChartMainFragment.OnListItemClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //视频为了避免闪屏和透明问题
        getWindow().setFormat(PixelFormat.TRANSLUCENT);
        setContentView(R.layout.activity_chart);
        if (savedInstanceState == null) {
            ChartMainFragment mainFragment = new ChartMainFragment();
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.content, mainFragment)
                    .commit();
        }
    }
    @Override
    public void onListItemClick(int position) {
        Intent intent = new Intent(this, ChartWebViewActivity.class);
        switch (position) {
            case 0:
                intent.putExtra("url", "http://192.168.200.156:8888/echart");
                break;
            case 1:
                intent.putExtra("url", "http://192.168.200.156:8888/echart2");
                break;
            case 2:
                intent.putExtra("url", "http://192.168.200.156:8888/echart3");
                break;
            default:
                break;
        }
        startActivity(intent);
//        getSupportFragmentManager().beginTransaction()
//                .replace(R.id.content, fragment)
//                .addToBackStack(null)
//                .commit();

    }
}
